using System;
using System.Collections;
using System.Runtime.InteropServices;
namespace BMC.ARSystem
{
	[ClassInterface, Guid("8a7fb3ec-f362-40be-a818-777824af2f4a"), ProgId("BMC.ARSystem.DiaryList")]
	public class DiaryList : CollectionBase
	{
		[Guid("8553eb46-f073-4a3b-ba03-781521641967")]
		public class Enumerator : IEnumerator
		{
			private IEnumerator wrapped;
			public DiaryEntry Current
			{
				get
				{
					return (DiaryEntry)this.wrapped.get_Current();
				}
			}
			object IEnumerator.Current
			{
				get
				{
					return (DiaryEntry)this.wrapped.get_Current();
				}
			}
			public Enumerator(DiaryList collection)
			{
				this.wrapped = collection.GetEnumerator();
			}
			public bool MoveNext()
			{
				return this.wrapped.MoveNext();
			}
			public void Reset()
			{
				this.wrapped.Reset();
			}
		}
		private string _appendedText;
		public virtual DiaryEntry this[int index]
		{
			get
			{
				return (DiaryEntry)base.get_List().get_Item(index);
			}
		}
		public string AppendedText
		{
			get
			{
				return this._appendedText;
			}
			set
			{
				this._appendedText = value;
			}
		}
		public virtual void Add(DiaryEntry value)
		{
			base.get_List().Add(value);
		}
		public virtual bool Contains(DiaryEntry value)
		{
			return base.get_List().Contains(value);
		}
		public virtual int IndexOf(DiaryEntry value)
		{
			return base.get_List().IndexOf(value);
		}
		public virtual DiaryList.Enumerator GetEnumerator()
		{
			return new DiaryList.Enumerator(this);
		}
		public override string ToString()
		{
			string text = "";
			foreach (DiaryEntry current in this)
			{
				object obj = text;
				text = string.Concat(new object[]
				{
					obj,
					current.Time.ToLocalTime(),
					"::",
					current.User,
					"::",
					current.Text,
					"\n"
				});
			}
			return text;
		}
		internal string Encode()
		{
			string text = "";
			DateTime dateTime = new DateTime(1970, 1, 1, 0, 0, 0);
			foreach (DiaryEntry current in this)
			{
				text += (current.Time - dateTime).get_TotalSeconds();
				text += '\u0004';
				text += current.User;
				text += '\u0004';
				string text2 = current.Text;
				text += text2;
				text += '\u0003';
			}
			return text;
		}
		public static DiaryList Decode(string encoded)
		{
			DiaryList diaryList = new DiaryList();
			if (encoded != null)
			{
				string[] array = encoded.Split(new char[]
				{
					'\u0003'
				});
				string[] array2 = array;
				for (int i = 0; i < array2.Length; i++)
				{
					string text = array2[i];
					if (text.get_Length() != 0)
					{
						string[] array3 = text.Split(new char[]
						{
							'\u0004'
						});
						if (array3.Length < 2)
						{
							throw new Exception("Diary decode error.");
						}
						string text2 = array3[0];
						uint unixTime = Convert.ToUInt32(text2);
						DateTime dateTime = Util.GetDateTime(unixTime);
						string user = array3[1];
						string combinedStringFromParts = Util.GetCombinedStringFromParts(array3, 2, '\u0004');
						DiaryEntry value = new DiaryEntry(user, dateTime, combinedStringFromParts);
						diaryList.Add(value);
					}
				}
			}
			return diaryList;
		}
	}
}
